package org.nstack.header.zone;

import org.nstack.header.message.APICreateMessage;
import org.nstack.header.message.APIEvent;
import org.nstack.header.message.APIMessage;
import org.nstack.header.message.APIParam;
import org.springframework.http.HttpMethod;
import org.nstack.header.notification.ApiNotification;
import org.nstack.header.rest.APINoSee;
import org.nstack.header.rest.RestRequest;


@RestRequest(
        path = "/zones",
        method = HttpMethod.POST,
        parameterName = "params",
        responseClass = APICreateZoneEvent.class
)
public class APICreateZoneMsg extends APICreateMessage {

    @APIParam(maxLength = 255)
    private String name;

    @APIParam(required = false, maxLength = 2048)
    private String description;

    @APIParam(required = false, validValues = {" nstack"})
    @APINoSee
    private String type;

    public String getDescription() {
        return description;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setDescription(String description) {
        this.description = description;
    }
 
    public static APICreateZoneMsg __example__() {
        APICreateZoneMsg msg = new APICreateZoneMsg();
        msg.setName("TestZone");
        msg.setDescription("test zone");
        return msg;
    }

    public ApiNotification __notification__() {
        APIMessage that = this;

        return new ApiNotification() {
            @Override
            public void after(APIEvent evt) {
                if (evt.isSuccess()) {
                    ntfy("Created").resource(((APICreateZoneEvent)evt).getInventory().getUuid(), ZoneVO.class.getSimpleName())
                            .messageAndEvent(that, evt).done();
                }
            }
        };
    }

}
